local BlessPanel = require "View/BillBoard/BlessPanel"
local ArenaPanel = require "View/BillBoard/ArenaPanel"
local TowerPanel = require "View/BillBoard/TowerPanel"
local MythicPanel = require "View/BillBoard/MythicPanel"
local SocialPanel = require "View/BillBoard/SocialPanel"
local ChaosPanel = require "View/BillBoard/ChaosPanel"

---@class BillBoardPanel : UIComponentBase
local BillBoardPanel = Class("BillBoardPanel",UIComponentBase)
local t = BillBoardPanel

function t:OnCreate()
    ---@type Billboard_BlessPanel
    self.bless = self:CreateComponent(BlessPanel,self:GetChild("bless"))
    ---@type Billboard_ArenaPanel
    self.arena = self:CreateComponent(ArenaPanel,self:GetChild("arena"))
    ---@type Billboard_TowerPanel
    self.tower = self:CreateComponent(TowerPanel,self:GetChild("tower"))
    ---@type Billboard_MythicPanel
    self.mythic = self:CreateComponent(MythicPanel,self:GetChild("mythic"))
    ---@type Billboard_SocialPanel
    self.social = self:CreateComponent(SocialPanel,self:GetChild("social"))
    ---@type Billboard_ChaosPanel
    self.Chaos = self:CreateComponent(ChaosPanel,self:GetChild("chaos"))
    self.isFirstEnter = true
end

function t:OnEnable()
    self:RegisterEvent(Config.EventType.RefreshNoticeGetReward,self.NoticeGetRewardMsg)
    self:RegisterEvent(Config.EventType.RefreshNoticeMainRank,self.NoticeMainRankMsg)
    self:RegisterEvent(Config.EventType.Fresh_TowerRanks, self.GetTowerAllData)
    self:RegisterEvent(Config.EventType.Fresh_ArenaRanks,self.RefreshArenaWithData)
    self:RegisterEvent(Config.EventType.Fresh_MythicRanks,self.RefreshMythicWithData)
    self:RegisterEvent(Config.EventType.Trials_Chaos_Work_Rank,self.RefreshChaosWithData)
end
function t:OnDisable()
    self:UnRegisterEvent()
end
function t:OnDestroy()
end
function t:Open()

    TrialHandel.SendTrialsWorldRank()
    --mythicDungeonsHandler.ReqInstanceGetRanks()
    mythicDungeonsProHandler.ReqInstanceGetRanks()
    logicMgr.TowerManager.sendGetRanks(1)
    logicMgr.ArenaManager.requestRankInfo()
    dungeonHandler.ReqHardDungeonRankList()  -- 请求幻魔之旅排行榜信息
   -- if logicMgr.NoticeManager.buffId == 0 then
        NoticeHandler.ReqRankWish()
    --end
    self.isFirstEnter = false
end
function t:NoticeGetRewardMsg(type)
    if type == logicMgr.NoticeManager.RankType.arena then
        self.arena:RefreshReward()
    elseif type == logicMgr.NoticeManager.RankType.mythic then
        self.mythic:RefreshReward()
    elseif type == logicMgr.NoticeManager.RankType.tower then
        self.tower:RefreshReward()
    -- elseif type == logicMgr.NoticeManager.RankType.social then
    --     self.social:RefreshReward()
    elseif type == logicMgr.NoticeManager.RankType.Chaos then
        self.Chaos:RefreshReward()
    elseif type == logicMgr.NoticeManager.RankType.Level then
        self.social:RefreshReward() 
    end
end
function t:NoticeMainRankMsg(type)
    if type == logicMgr.NoticeManager.RankType.mythic then
        self.mythic:GetAllData()
    elseif type == logicMgr.NoticeManager.RankType.tower then
        self.tower:GetAllData()
    elseif type == logicMgr.NoticeManager.RankType.arena then
        self.arena:GetAllData()
    -- elseif type == logicMgr.NoticeManager.RankType.social then
    --     self.social:GetAllData()
    elseif type == logicMgr.NoticeManager.RankType.Level then
        self.social:GetAllData()
    end
end
function t:GetTowerAllData()
    self.tower:GetAllData()
end
function t:RefreshArenaWithData()
    self.arena:GetAllData()
end
function t:RefreshChaosWithData()
    self.Chaos:GetAllData()
end
function t:RefreshMythicWithData()
    self.mythic:GetAllData()
end
return t